setwd("~/Cline_disp_evol/Balkau_orig/ran_outs")

source("~/evo-dispersal/Disp_clines/Balkau_orig_functions.R")

### initialise ###
args=(commandArgs(TRUE))

#evaluate the arguments
# input arguments will be s, m, r, ID

for(i in 1:length(args)) {
   eval(parse(text=args[[i]]))
}

Ni<-5000
bvec<-seq(-5, 5, 1)
bvec<-logistic.m(bval=bvec, m=m)

ptable<-c()
for (ii in 1:length(bvec)){
  pop<-iterator(Ni=Ni, s=s, m=m, bval=bvec[ii], init.gens=100, final.gens=10000, demog=F)
  prop<-table(factor(pop[,"hapB"], levels=c(0,1)))/(2*Ni)
  ptable<-rbind(ptable, prop)

}

ptable<-cbind(s=rep(s, nrow(ptable)), m=rep(m, nrow(ptable)), r=rep(r, nrow(ptable)), m.star=m+bvec, ptable)

save(ptable, file=paste("balkau_orig", ID, ".RData", sep=""))
